<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>修改故障</title>
<link rel="stylesheet" href="../layui/css/layui.css">
<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
<style>
    .content{
        padding-top:10px;
    }
    .button{
        margin-top: 20px;
    }
    .content .layui-form-label{
        margin-top: 10px;
    }
    .content .layui-input-block{
        width: 75%;
        margin-top: 10px;
    }
</style>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <!--form表单-->
    <div class="layui-form">
        <!--标题-->
        <div class="layui-form-item content">
            <label class="layui-form-label">角色名称</label>
            <div  class="layui-input-block">
                <input type="text" id="roleName" name="roleName"  required lay-verify="required" placeholder="请输入角色名称" autocomplete="off" class="layui-input">
            </div>
            <input type="text" id="roleId" hidden="hidden" name="roleId"  required lay-verify="required"  autocomplete="off">
        </div>

        <!--操作-->
        <div class="layui-form-item" id="operating">
            <div class="layui-input-block">
                <button class="layui-btn button" lay-submit lay-filter="formDemo">提交</button>
                <button  class="layui-btn layui-btn-primary button" id="exit" value="取消">取消</button>
            </div>
        </div>
    </div>
</div>
<script src="../layui/layui.js"></script>
<script src="../js/public.js"></script>
<script>
    var header = {
        Authorization: window.localStorage.getItem("Authorization")
        , userid: window.localStorage.getItem("userid")
    }
    layui.use(['form','element','layer'],function () {
        var form = layui.form;
        var element = layui.element;
        var layer = layui.layer;
        //点击取消，关闭页面
        $("#exit").click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
            form.on('submit(formDemo)',function (data) {
                var parm=data.field;
                $.ajax({
                    url:role.update,
                    type:"post",
                    headers:header,
                    contentType: 'application/json',
                    data:JSON.stringify(parm),
                    success:function (res) {
                        if (res.status==0){
                            layer.open({
                                title: '提示'
                                ,content: '修改成功'
                                ,yes:function(index, layero) {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                }});
                        } else if (res.status==-2) {
                            layer.confirm('身份过期，重新登录',{btn:['知道了'],
                                cancel: function(index, layero){
                                    //取消操作，点击右上角的X
                                    parent.location.href = "../login.html";
                                }},function(index){
                                parent.location.href = "../login.html";
                            });
                        }else{
                            layer.open({
                                title: '提示'
                                ,content: '修改失败'
                                ,yes:function(index, layero) {
                                    location.reload();
                            }});
                        }
                    }
                })
            })
    });
</script>
</body>
</html>
